@extends('Layout.admin')
@section('content')
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="col-md-12" >
            <div class="app_content_div" id="app_content_div_301Index">
                <h3>新增专家</h3>
            </div>
            <form class="form-horizontal">
                <div class="form-group">
                    <label for="name" class="col-sm-2 control-label"><span style="color:red;">*</span>姓名</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="name" name="name" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="upload_file" class="col-sm-2 control-label"><span style="color:red;">*</span>缩略图</label>
                    <div class="col-sm-10">
                        <input  id="thumb" name="thumb"  type="file" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="department" class="col-sm-2 control-label"><span style="color:red;">*</span>科室</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="department" name="department" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="title" class="col-sm-2 control-label"><span style="color:red;">*</span>职称</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="title" name="title" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="duties" class="col-sm-2 control-label"><span style="color:red;">*</span>职务</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="duties" name="duties" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="hospital" class="col-sm-2 control-label"><span style="color:red;">*</span>医院</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="hospital" name="hospital">
                    </div>
                </div>
                <div class="form-group">
                    <label for="content" class="col-sm-2 control-label"><span style="color:red;">*</span>简介</label>
                    <div class="col-sm-10">
                        <script id="content"  type="text/plain"></script>
                    </div>
                </div>
                <script type="text/javascript">
                    var ue1 = UE.getEditor('content',{
                        elementPathEnabled: false,
                        saveInterval: 5000
                    });</script>
                <div class="form-group">
                    <label for="edu" class="col-sm-2 control-label"><span style="color:red;">*</span>接受教育</label>
                    <div class="col-sm-10">
                        <script id="edu"  type="text/plain"></script>
                    </div>
                </div>
                <script type="text/javascript">
                    var ue2 = UE.getEditor('edu',{
                        elementPathEnabled: false,
                        saveInterval: 5000
                    });
                </script>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" onclick="check()" class="btn btn-default">确定</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript" >
        function check(){
            var name = $('#name').val();
            var department= $('#department').val();
            var title= $('#title').val();
            var duties= $('#duties').val();
            var hospital = $('#hospital').val();
            let content=ue1.getContentTxt();
            let edu=ue2.getContentTxt();
            var _token = "{{csrf_token()}}";
            $.ajaxFileUpload({
                url:'/adm/extert/add-extert',
                type:'post',
                fileElementId:'thumb',
                dataType:'json',
                data:{'name':name, 'department':department,
                    'title':title, 'duties':duties,
                    'hospital':hospital, 'content':content,
                    'edu':edu, '_token':_token},
                success:function (data){
                    if(data.success){
                        alert(data.msg);
                        location.href='/adm/extert';
                    }else{
                        alert(data.msg);
                    }
                }
            });

        }
    </script>@endsection
